﻿using nblTool.utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using WebFirst.Entities;

namespace Jn698._45Tool.Service
{
    internal class GWCmdMakeUpPlanService : IService<GWCmdMakeUpPlan>
    {
        public int Delete(GWCmdMakeUpPlan t)
        {
            throw new NotImplementedException();
        }

        public int DeleteAll()
        {
            throw new NotImplementedException();
        }

        public int Insert(GWCmdMakeUpPlan t)
        {
            throw new NotImplementedException();
        }

        public GWCmdMakeUpPlan Select(int Id)
        {
            return SqlSugarHelper.Db.Queryable<GWCmdMakeUpPlan>().Single(x => x.Id == Id);
        }

        public List<GWCmdMakeUpPlan> Select(string OAD)
        {
            
            return SqlSugarHelper.Db.Queryable<GWCmdMakeUpPlan>().Where(g => g.ObjectIdentifier.Equals(OAD)).ToList();
        }
        public List<GWCmdMakeUpPlan> Select(string OAD,string APDU)
        {

            return SqlSugarHelper.Db.Queryable<GWCmdMakeUpPlan>().Where(g => g.ObjectIdentifier.Equals(OAD)).Where(g=>g.OpenrateType.Equals(APDU)).ToList();
        }
        public List<GWCmdMakeUpPlan> Select(ObjectID objectID)
        {
            int AttributeID = (int)objectID.AttributeID;
            string OAD;
            if (objectID._ObjectID.Length==4)
            {
                OAD = objectID._ObjectID.ToString() + AttributeID.ToString("X2") + "00";
            }
            else
            {
                OAD = objectID._ObjectID.ToString();
                
            }
            
            return SqlSugarHelper.Db.Queryable<GWCmdMakeUpPlan>().Where(g => g.ObjectIdentifier.Equals(OAD)).Where(g=>g.OpenrateType.Equals(objectID.ClientAPDU)).ToList();
        }
        public List<GWCmdMakeUpPlan> Select(BatchParaConfig batchParaConfig)
        {

            return SqlSugarHelper.Db.Queryable<GWCmdMakeUpPlan>().Where(g => g.ObjectIdentifier.Equals(batchParaConfig.StrOAD)).Where(g => g.OpenrateType.Equals(batchParaConfig.ClientAPDU)).ToList();
        }
        public List<GWCmdMakeUpPlan> Select()
        {
            throw new NotImplementedException();
        }

        public int Update(GWCmdMakeUpPlan t)
        {
            return SqlSugarHelper.Db.Updateable(t).ExecuteCommand();
        }
        public int UpdateValue(GWCmdMakeUpPlan t)
        {
            return SqlSugarHelper.Db.Updateable(t).UpdateColumns(g => new { g.DataValue}).ExecuteCommand();
        }

        GWCmdMakeUpPlan IService<GWCmdMakeUpPlan>.Select(string Name)
        {
            throw new NotImplementedException();
        }
    }
}
